﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Core;
using System.Data.SqlClient;
using System.Data;
using BestLifePOS_Core.Exceptions.DataBase;

namespace BestLifePOS_Core.Data.Commands
{
    class BestLifeUpdateSTNDataAction : BestLifeDataAction<int>
    {
         private string Gvxml;     
       private string GvStatus;
       public BestLifeUpdateSTNDataAction(string PGRNList, string PStatus)
        {

            Gvxml = PGRNList;
            GvStatus = PStatus;
        }

        public override int Body(SqlConnection PConn)
        {
            try
            {
                    SqlCommand LvCommand = new SqlCommand();
                    LvCommand.Connection = PConn;
                    LvCommand.CommandType = CommandType.StoredProcedure;
                    LvCommand.CommandText = "dbo.UpdateSTN";
                    LvCommand.Parameters.AddWithValue("@STNdetails", Gvxml);//when passing parameters to the SP                  
                    LvCommand.Parameters.AddWithValue("@status", GvStatus.ToString());

                  int   LvCount = LvCommand.ExecuteNonQuery();
                     
                     
               
                return LvCount; 
                
            }
            catch (BestlifeDatabaseException e)
            {
                throw new BestlifeDatabaseException(e);
            }
        }

    }
}
